package com.sgzn.sgpay.web.controller;

import com.sgzn.sgpay.model.request.SgsUserInfoQueryRequest;
import com.sgzn.sgpay.model.response.SgsResultResponse;
import com.sgzn.sgpay.model.response.SgsUserInfoQueryResponse;
import com.sgzn.sgpay.model.response.vo.UserMerchantDiscountVo;
import com.sgzn.sgpay.service.SgsUserInfoService;
import com.sgzn.sgpay.web.controller.base.UserBaseController;
import com.sgzn.sgpay.web.handle.AssembleCommonHandle;
import com.sgzn.sgpay.web.request.Impl.UserInfoRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author huangsenguang
 * @version Id: UserInfoController.java, v 0.1 2018/4/22 11:06 huangsenguang Exp $$
 */
@Slf4j
@Controller
@RequestMapping("/user")
public class UserInfoController extends UserBaseController{
    @Autowired
    private SgsUserInfoService sgsUserInfoService;
    @Resource
    private AssembleCommonHandle assembleCommonHandle;

    @RequestMapping("queryInfo")
    @ResponseBody
    public SgsResultResponse<SgsUserInfoQueryResponse> queryUserInfo(UserInfoRequest request){
        super.setUserInfo(request);
        return this.sgsUserInfoService.queryUserInfo(assembleQueryInfoRequest(request));
    }

    private SgsUserInfoQueryRequest assembleQueryInfoRequest(UserInfoRequest request) {
        SgsUserInfoQueryRequest sgsUserInfoQueryRequest = new SgsUserInfoQueryRequest();
        assembleCommonHandle.assembleUserRequest(request, sgsUserInfoQueryRequest);
        return sgsUserInfoQueryRequest;
    }


    @RequestMapping("queryDiscount")
    @ResponseBody
    public SgsResultResponse<List<UserMerchantDiscountVo>> queryUserDiscountListInfo(UserInfoRequest request){
        super.setUserInfo(request);
        return this.sgsUserInfoService.queryUserMerchantDiscountListInfo(assembleQueryInfoRequest(request));


    }



}

